[NativeAOT] Do not overwrite throw frame with first rethrow frame#123763
Merged
rcj1 merged 1 commit intodotnet:mainfrom Jan 30, 2026
Merged
[NativeAOT] Do not overwrite throw frame with first rethrow frame#123763rcj1 merged 1 commit intodotnet:mainfrom
rcj1 merged 1 commit intodotnet:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug in NativeAOT where exception stack traces incorrectly showed the location of a throw; rethrow statement instead of the original throw location. The fix aligns NativeAOT's behavior with CoreCLR by skipping stack frame recording during rethrow operations, preserving the original throw location.
Changes:
- Modified
AppendStackIPto remove theisFirstRethrowFrameparameter and the logic that overwrote stack frames during rethrows - Updated
AppendExceptionStackFrameto skip callingAppendStackIPentirely whenisFirstRethrowFrameis true
Contributor
|
Fixes #107507? |
Member
|
/azp run runtime-nativeaot-outerloop |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Member
|
LGTM once runtime-nativeaot-outerloop shows no regressions related to this change. |
This was referenced Jan 30, 2026
Open
Member
|
/ba-g infrastructure timeouts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently in NativeAOT, we overwrite the stack trace frame before a rethrow with the rethrow frame. This means that for the following code:
The exception stacktrace includes
throw new Exceptionandthrow, as opposed tothrow new ExceptionandTest2(). This was spotted as a bug in #9518 and fixed in dotnet/coreclr#16464; the corresponding coreclr code isruntime/src/coreclr/vm/exceptionhandling.cpp
Line 2992 in 59b270c
Fixes #107507?